package com.trailwalker.mediaplayer.dao;

import java.sql.ResultSet;

/**
 * @author Trailwalker
 * @create 2021-09-03 13:38
 * @des
 */
public class DatabaseUtils {

    private DatabaseInterface h2DatabaseUtils;

    public DatabaseUtils(String jdbcUrl) {
        h2DatabaseUtils = new H2DatabaseUtils(jdbcUrl);
    }

    public boolean createTable(String sql) {
        return h2DatabaseUtils.execute(sql);
    }

    public int insert(String sql) {
        return h2DatabaseUtils.executeUpdate(sql);
    }

    public int delete(String sql) {
        return h2DatabaseUtils.executeUpdate(sql);
    }

    public int update(String sql) {
        return h2DatabaseUtils.executeUpdate(sql);
    }

    public ResultSet query(String sql) {
        return h2DatabaseUtils.executeQuery(sql);
    }

    public void release() {
        h2DatabaseUtils.release();
    }
}
